package gitee.derumin.lifeissohard.item;

import gitee.derumin.lifeissohard.lishhungersystem.LishHungerManager;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.List;


public class BloodTesterUsed extends Item {

    public static final String TEST_SUCCESS = "TestSuccess";
    public static final String TEST_TIME = "TestTime";
    public static final String TESTED_PERSON = "TestedPerson";

    public BloodTesterUsed(Item.Settings settings){
        super(settings);
    }

    @Override
    public boolean hasGlint(ItemStack stack) {
        return true;
    }

    @Override
    public void appendTooltip(ItemStack itemStack, @Nullable World world, List<Text> tooltip, TooltipContext tooltipContext) {
        if(itemStack.getNbt() != null) {
            if (itemStack.getNbt().getBoolean(TEST_SUCCESS)) {
                tooltip.add(Text.translatable("item.lifeissohard.blood_tester_used.test_time").formatted(Formatting.DARK_AQUA));
                tooltip.add(Text.literal(itemStack.getNbt().getString(TEST_TIME)).formatted(Formatting.DARK_AQUA).formatted(Formatting.ITALIC));
                tooltip.add(Text.translatable("item.lifeissohard.blood_tester_used.tested_person").formatted(Formatting.DARK_AQUA));
                tooltip.add(Text.literal(itemStack.getNbt().getString(TESTED_PERSON)).formatted(Formatting.DARK_AQUA).formatted(Formatting.ITALIC));
                tooltip.add(Text.translatable("item.lifeissohard.blood_tester_used.heavy_metal").formatted(Formatting.GOLD));
                tooltip.add(Text.literal((itemStack.getNbt().getString(LishHungerManager.HEAVY_METAL)+" (0)")).formatted(Formatting.GOLD).formatted(Formatting.ITALIC));
                tooltip.add(Text.translatable("item.lifeissohard.blood_tester_used.blood_sugar").formatted(Formatting.GRAY));
                tooltip.add(Text.literal((itemStack.getNbt().getString(LishHungerManager.BLOOD_SUGAR)+" (3780)")).formatted(Formatting.GRAY).formatted(Formatting.ITALIC));
                tooltip.add(Text.translatable("item.lifeissohard.blood_tester_used.blood_fat").formatted(Formatting.YELLOW));
                tooltip.add(Text.literal((itemStack.getNbt().getString(LishHungerManager.BLOOD_FAT)+" (21450)")).formatted(Formatting.YELLOW).formatted(Formatting.ITALIC));
                tooltip.add(Text.translatable("item.lifeissohard.blood_tester_used.va").formatted(Formatting.RED));
                tooltip.add(Text.literal((itemStack.getNbt().getString(LishHungerManager.VA)+" (800)")).formatted(Formatting.RED).formatted(Formatting.ITALIC));
                tooltip.add(Text.translatable("item.lifeissohard.blood_tester_used.vb").formatted(Formatting.LIGHT_PURPLE));
                tooltip.add(Text.literal((itemStack.getNbt().getString(LishHungerManager.VB)+" (120)")).formatted(Formatting.LIGHT_PURPLE).formatted(Formatting.ITALIC));
                tooltip.add(Text.translatable("item.lifeissohard.blood_tester_used.vc").formatted(Formatting.DARK_GREEN));
                tooltip.add(Text.literal((itemStack.getNbt().getString(LishHungerManager.VC)+" (1000)")).formatted(Formatting.DARK_GREEN).formatted(Formatting.ITALIC));
                tooltip.add(Text.translatable("item.lifeissohard.blood_tester_used.iodine").formatted(Formatting.DARK_PURPLE));
                tooltip.add(Text.literal((itemStack.getNbt().getString(LishHungerManager.IODINE)+" (150)")).formatted(Formatting.DARK_PURPLE).formatted(Formatting.ITALIC));
            }
            else {
                tooltip.add(Text.translatable("item.lifeissohard.blood_tester_used.failed").formatted(Formatting.DARK_PURPLE).formatted(Formatting.ITALIC));
            }
        }
    }


}
